#!/bin/bash
echo 'Processing all raw files'

for x in `ls -1 *.raw`
do 	
	echo $x
	p1=$(echo $x | cut -d _ -f 1)
	p2=$(echo $x | cut -d _ -f 2)
	p3=$(echo $x | cut -d _ -f 3)
	if [ -d oggs/$p1/$p2/$p3 ];
	then
		echo 'Folder already exists.'
	else
		echo 'Creating new folder.'
		mkdir -p oggs/$p1/$p2/$p3 
	fi
	
	sox -r 8000 -u -1 -c 1 $x oggs/$p1/$p2/$p3/${x%raw}ogg 
	mv $x raw/$x
done


